<?php
/**
 * Created by PhpStorm.
 * User: Loong
 * Date: 2021/7/17
 * Time: 11:03
 */
namespace app\admin\logic;

use think\facade\Request;
use think\facade\View;

class Brand
{





    public static function setWhere()
    {
        //賦值 渲染頁面
        View::assign(input());


        $where = [];
        $whereOr = [];
        $keywords = Request::param('keywords');
        $recommended = Request::param('recommended');
        $show = Request::param('if_show',[]);
        $imgs = Request::param('imgs',[]);
        if (!empty($keywords)) $where[] = ['brand_name','like',"%{$keywords}%"];
        if ($recommended <> '') $where[] = ['recommended','=',$recommended];
        if (count($show) == 1) $where[] = ['if_show','in',$show];
        if (count($imgs) == 1){
            if ($imgs[0] == 0){
                $whereOr[] = ['brand_logo','=',''];
                $whereOr[] = ['brand_logo','=',null];
            }
            if ($imgs[0] == 1){
                $where[] = ['brand_logo','<>',''];
            }
        }
        //return [
        //    'where' =>$where,
        //    'whereOr' =>$whereOr
        //];
        return  [$where,$whereOr];

    }







}